import java.util.Date;
import java.util.ArrayList;
public class Accont
{
    private static long tot=0;
    private long   id;
    private String name;
    private Date   openTime;
    private String idCard;
    private double balance;
    ArrayList<String> log = new ArrayList<String>();
    public Accont(final String name,final String idCard)
    {
        this.id=this.tot;
        ++this.tot;
        this.name=name;
        this.openTime=new Date();
        this.idCard=idCard;
        this.balance=0;
        this.log=new ArrayList<String>();
    }
    public Accont(final Accont accont)
    {
        this.id=accont.tot;
        this.name=accont.name;
        this.openTime=accont.openTime;
        this.idCard=accont.idCard;
        this.balance=accont.balance;
        this.log=accont.log;
    }
    public String toString()
    {
        return "id: "+id+"\tname: "+name+"\topenTime: "+openTime+"\tidCard: "+idCard+"\tbalance:"+balance;
    }
    public String getLog()
    {
        return log.toString();
    }
    public void saveMoney(final double money)
    {
        balance+=money;
        log.add("Save money "+money+" at "+(new Date()));
    }
    public boolean getMoney(final double money)
    {
        if(balance>=money)
        {
            balance-=money;
            log.add("Get money "+money+" at "+(new Date()));
            return true;
        }
        log.add("Get money "+money+" failed at "+(new Date()));
        return false;
    }
}
